\(\int \tan ^2(x) \sqrt {a+a \tan ^2(x)} \, dx\) [259]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [F(-1)]

Optimal result

Integrand size = 17, antiderivative size = 36 \[ \int \tan ^2(x) \sqrt {a+a \tan ^2(x)} \, dx=-\frac {1}{2} \text {arctanh}(\sin (x)) \cos (x) \sqrt {a \sec ^2(x)}+\frac {1}{2} \sqrt {a \sec ^2(x)} \tan (x) \]

[Out]

-1/2*arctanh(sin(x))*cos(x)*(a*sec(x)^2)^(1/2)+1/2*(a*sec(x)^2)^(1/2)*tan(x)

Rubi [A] (verified)

Time = 0.12 (sec) , antiderivative size = 36, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.235, Rules used = {3738, 4210, 2691, 3855} \[ \int \tan ^2(x) \sqrt {a+a \tan ^2(x)} \, dx=\frac {1}{2} \tan (x) \sqrt {a \sec ^2(x)}-\frac {1}{2} \cos (x) \sqrt {a \sec ^2(x)} \text {arctanh}(\sin (x)) \]

[In]

Int[Tan[x]^2*Sqrt[a + a*Tan[x]^2],x]

[Out]

-1/2*(ArcTanh[Sin[x]]*Cos[x]*Sqrt[a*Sec[x]^2]) + (Sqrt[a*Sec[x]^2]*Tan[x])/2

Rule 2691

Int[((a_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(a*Sec[e +
 f*x])^m*((b*Tan[e + f*x])^(n - 1)/(f*(m + n - 1))), x] - Dist[b^2*((n - 1)/(m + n - 1)), Int[(a*Sec[e + f*x])
^m*(b*Tan[e + f*x])^(n - 2), x], x] /; FreeQ[{a, b, e, f, m}, x] && GtQ[n, 1] && NeQ[m + n - 1, 0] && Integers
Q[2*m, 2*n]

Rule 3738

Int[(u_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]^2)^(p_), x_Symbol] :> Int[ActivateTrig[u*(a*sec[e + f*x]^2)^p]
, x] /; FreeQ[{a, b, e, f, p}, x] && EqQ[a, b]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rule 4210

Int[(u_.)*((b_.)*sec[(e_.) + (f_.)*(x_)]^(n_))^(p_), x_Symbol] :> With[{ff = FreeFactors[Sec[e + f*x], x]}, Di
st[(b*ff^n)^IntPart[p]*((b*Sec[e + f*x]^n)^FracPart[p]/(Sec[e + f*x]/ff)^(n*FracPart[p])), Int[ActivateTrig[u]
*(Sec[e + f*x]/ff)^(n*p), x], x]] /; FreeQ[{b, e, f, n, p}, x] &&  !IntegerQ[p] && IntegerQ[n] && (EqQ[u, 1] |
| MatchQ[u, ((d_.)*(trig_)[e + f*x])^(m_.) /; FreeQ[{d, m}, x] && MemberQ[{sin, cos, tan, cot, sec, csc}, trig
]])

Rubi steps \begin{align*} \text {integral}& = \int \sqrt {a \sec ^2(x)} \tan ^2(x) \, dx \\ & = \left (\cos (x) \sqrt {a \sec ^2(x)}\right ) \int \sec (x) \tan ^2(x) \, dx \\ & = \frac {1}{2} \sqrt {a \sec ^2(x)} \tan (x)-\frac {1}{2} \left (\cos (x) \sqrt {a \sec ^2(x)}\right ) \int \sec (x) \, dx \\ & = -\frac {1}{2} \text {arctanh}(\sin (x)) \cos (x) \sqrt {a \sec ^2(x)}+\frac {1}{2} \sqrt {a \sec ^2(x)} \tan (x) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.06 (sec) , antiderivative size = 24, normalized size of antiderivative = 0.67 \[ \int \tan ^2(x) \sqrt {a+a \tan ^2(x)} \, dx=\frac {1}{2} \sqrt {a \sec ^2(x)} (-\text {arctanh}(\sin (x)) \cos (x)+\tan (x)) \]

[In]

Integrate[Tan[x]^2*Sqrt[a + a*Tan[x]^2],x]

[Out]

(Sqrt[a*Sec[x]^2]*(-(ArcTanh[Sin[x]]*Cos[x]) + Tan[x]))/2

Maple [A] (verified)

Time = 0.07 (sec) , antiderivative size = 39, normalized size of antiderivative = 1.08

method result size
derivativedivides \(\frac {\sqrt {a +a \tan \left (x \right )^{2}}\, \tan \left (x \right )}{2}-\frac {\sqrt {a}\, \ln \left (\sqrt {a}\, \tan \left (x \right )+\sqrt {a +a \tan \left (x \right )^{2}}\right )}{2}\) \(39\)
default \(\frac {\sqrt {a +a \tan \left (x \right )^{2}}\, \tan \left (x \right )}{2}-\frac {\sqrt {a}\, \ln \left (\sqrt {a}\, \tan \left (x \right )+\sqrt {a +a \tan \left (x \right )^{2}}\right )}{2}\) \(39\)
risch \(-\frac {i \sqrt {\frac {a \,{\mathrm e}^{2 i x}}{\left ({\mathrm e}^{2 i x}+1\right )^{2}}}\, \left ({\mathrm e}^{2 i x}-1\right )}{{\mathrm e}^{2 i x}+1}+\sqrt {\frac {a \,{\mathrm e}^{2 i x}}{\left ({\mathrm e}^{2 i x}+1\right )^{2}}}\, \ln \left ({\mathrm e}^{i x}-i\right ) \cos \left (x \right )-\sqrt {\frac {a \,{\mathrm e}^{2 i x}}{\left ({\mathrm e}^{2 i x}+1\right )^{2}}}\, \ln \left ({\mathrm e}^{i x}+i\right ) \cos \left (x \right )\) \(100\)

[In]

int((a+a*tan(x)^2)^(1/2)*tan(x)^2,x,method=_RETURNVERBOSE)

[Out]

1/2*(a+a*tan(x)^2)^(1/2)*tan(x)-1/2*a^(1/2)*ln(a^(1/2)*tan(x)+(a+a*tan(x)^2)^(1/2))

Fricas [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 47, normalized size of antiderivative = 1.31 \[ \int \tan ^2(x) \sqrt {a+a \tan ^2(x)} \, dx=\frac {1}{4} \, \sqrt {a} \log \left (2 \, a \tan \left (x\right )^{2} - 2 \, \sqrt {a \tan \left (x\right )^{2} + a} \sqrt {a} \tan \left (x\right ) + a\right ) + \frac {1}{2} \, \sqrt {a \tan \left (x\right )^{2} + a} \tan \left (x\right ) \]

[In]

integrate((a+a*tan(x)^2)^(1/2)*tan(x)^2,x, algorithm="fricas")

[Out]

1/4*sqrt(a)*log(2*a*tan(x)^2 - 2*sqrt(a*tan(x)^2 + a)*sqrt(a)*tan(x) + a) + 1/2*sqrt(a*tan(x)^2 + a)*tan(x)

Sympy [F]

\[ \int \tan ^2(x) \sqrt {a+a \tan ^2(x)} \, dx=\int \sqrt {a \left (\tan ^{2}{\left (x \right )} + 1\right )} \tan ^{2}{\left (x \right )}\, dx \]

[In]

integrate((a+a*tan(x)**2)**(1/2)*tan(x)**2,x)

[Out]

Integral(sqrt(a*(tan(x)**2 + 1))*tan(x)**2, x)

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 295 vs. \(2 (28) = 56\).

Time = 0.57 (sec) , antiderivative size = 295, normalized size of antiderivative = 8.19 \[ \int \tan ^2(x) \sqrt {a+a \tan ^2(x)} \, dx=\frac {{\left (4 \, {\left (\sin \left (3 \, x\right ) - \sin \left (x\right )\right )} \cos \left (4 \, x\right ) - {\left (2 \, {\left (2 \, \cos \left (2 \, x\right ) + 1\right )} \cos \left (4 \, x\right ) + \cos \left (4 \, x\right )^{2} + 4 \, \cos \left (2 \, x\right )^{2} + \sin \left (4 \, x\right )^{2} + 4 \, \sin \left (4 \, x\right ) \sin \left (2 \, x\right ) + 4 \, \sin \left (2 \, x\right )^{2} + 4 \, \cos \left (2 \, x\right ) + 1\right )} \log \left (\cos \left (x\right )^{2} + \sin \left (x\right )^{2} + 2 \, \sin \left (x\right ) + 1\right ) + {\left (2 \, {\left (2 \, \cos \left (2 \, x\right ) + 1\right )} \cos \left (4 \, x\right ) + \cos \left (4 \, x\right )^{2} + 4 \, \cos \left (2 \, x\right )^{2} + \sin \left (4 \, x\right )^{2} + 4 \, \sin \left (4 \, x\right ) \sin \left (2 \, x\right ) + 4 \, \sin \left (2 \, x\right )^{2} + 4 \, \cos \left (2 \, x\right ) + 1\right )} \log \left (\cos \left (x\right )^{2} + \sin \left (x\right )^{2} - 2 \, \sin \left (x\right ) + 1\right ) - 4 \, {\left (\cos \left (3 \, x\right ) - \cos \left (x\right )\right )} \sin \left (4 \, x\right ) + 4 \, {\left (2 \, \cos \left (2 \, x\right ) + 1\right )} \sin \left (3 \, x\right ) - 8 \, \cos \left (3 \, x\right ) \sin \left (2 \, x\right ) + 8 \, \cos \left (x\right ) \sin \left (2 \, x\right ) - 8 \, \cos \left (2 \, x\right ) \sin \left (x\right ) - 4 \, \sin \left (x\right )\right )} \sqrt {a}}{4 \, {\left (2 \, {\left (2 \, \cos \left (2 \, x\right ) + 1\right )} \cos \left (4 \, x\right ) + \cos \left (4 \, x\right )^{2} + 4 \, \cos \left (2 \, x\right )^{2} + \sin \left (4 \, x\right )^{2} + 4 \, \sin \left (4 \, x\right ) \sin \left (2 \, x\right ) + 4 \, \sin \left (2 \, x\right )^{2} + 4 \, \cos \left (2 \, x\right ) + 1\right )}} \]

[In]

integrate((a+a*tan(x)^2)^(1/2)*tan(x)^2,x, algorithm="maxima")

[Out]

1/4*(4*(sin(3*x) - sin(x))*cos(4*x) - (2*(2*cos(2*x) + 1)*cos(4*x) + cos(4*x)^2 + 4*cos(2*x)^2 + sin(4*x)^2 +
4*sin(4*x)*sin(2*x) + 4*sin(2*x)^2 + 4*cos(2*x) + 1)*log(cos(x)^2 + sin(x)^2 + 2*sin(x) + 1) + (2*(2*cos(2*x)
+ 1)*cos(4*x) + cos(4*x)^2 + 4*cos(2*x)^2 + sin(4*x)^2 + 4*sin(4*x)*sin(2*x) + 4*sin(2*x)^2 + 4*cos(2*x) + 1)*
log(cos(x)^2 + sin(x)^2 - 2*sin(x) + 1) - 4*(cos(3*x) - cos(x))*sin(4*x) + 4*(2*cos(2*x) + 1)*sin(3*x) - 8*cos
(3*x)*sin(2*x) + 8*cos(x)*sin(2*x) - 8*cos(2*x)*sin(x) - 4*sin(x))*sqrt(a)/(2*(2*cos(2*x) + 1)*cos(4*x) + cos(
4*x)^2 + 4*cos(2*x)^2 + sin(4*x)^2 + 4*sin(4*x)*sin(2*x) + 4*sin(2*x)^2 + 4*cos(2*x) + 1)

Giac [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 40, normalized size of antiderivative = 1.11 \[ \int \tan ^2(x) \sqrt {a+a \tan ^2(x)} \, dx=\frac {1}{2} \, \sqrt {a} \log \left ({\left | -\sqrt {a} \tan \left (x\right ) + \sqrt {a \tan \left (x\right )^{2} + a} \right |}\right ) + \frac {1}{2} \, \sqrt {a \tan \left (x\right )^{2} + a} \tan \left (x\right ) \]

[In]

integrate((a+a*tan(x)^2)^(1/2)*tan(x)^2,x, algorithm="giac")

[Out]

1/2*sqrt(a)*log(abs(-sqrt(a)*tan(x) + sqrt(a*tan(x)^2 + a))) + 1/2*sqrt(a*tan(x)^2 + a)*tan(x)

Mupad [F(-1)]

Timed out. \[ \int \tan ^2(x) \sqrt {a+a \tan ^2(x)} \, dx=\int {\mathrm {tan}\left (x\right )}^2\,\sqrt {a\,{\mathrm {tan}\left (x\right )}^2+a} \,d x \]

[In]

int(tan(x)^2*(a + a*tan(x)^2)^(1/2),x)

[Out]

int(tan(x)^2*(a + a*tan(x)^2)^(1/2), x)